package com.hoperun.framework.jdbc.dialect;

public class MyBatisHSQLDialect extends Dialect {
	public boolean supportsLimit() {
		return true;
	}

	public boolean supportsLimitOffset() {
		return true;
	}

	public String getLimitString(String sql, int offset,
			String offsetPlaceholder, int limit, String limitPlaceholder) {
		int temp = 10;
		int tempInt = 6;
		boolean hasOffset = offset > 0;
		StringBuffer sb = new StringBuffer(sql.length() + 10);
		sb.append(sql);
		if (hasOffset) {
			sb.insert(sql.toLowerCase().indexOf("select") + 6, " limit "
					+ offsetPlaceholder + " " + limitPlaceholder);
		} else {
			sb.insert(sql.toLowerCase().indexOf("select") + 6, " top "
					+ limitPlaceholder);
		}
		return sb.toString();
	}
}